package com.surfilter.massdata.spark.model;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;

import java.io.IOException;
import java.util.Map;

import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.SearchHit;

import com.surfilter.massdata.es.core.entity.EsEntity;
import com.surfilter.massdata.spark.bean.massDomain.TopDomainIndex;

public class EsTopDomainVisits implements EsEntity<TopDomainIndex> {

	/**
	 *  String mappingStr = "{ \"goods\" : { \"properties\": { \"id\": { \"type\": \"long\" }, "
        		                                            + "\"name\": {\"type\": \"string\", \"analyzer\": \"ik_max_word\"}, "
        		                                            + "\"regionIds\": {\"type\": \"string\",\"index\": \"not_analyzed\"}}}}";
	 */
	@Override
	public XContentBuilder createMappingJson(String typeName) throws IOException {
		XContentBuilder mapping = jsonBuilder()
				.startObject()
					.startObject(typeName)
						.startObject("_source").field("enabled", true).endObject()
						.startObject("_all").field("enabled", false).endObject()
							.startObject("properties")
								.startObject("id").field("type","long").endObject()
								.startObject("topDomain").field("type","string").field("index","not_analyzed").endObject()
								.startObject("siteName").field("type","string").field("index","not_analyzed").endObject()
								.startObject("licenseKey").field("type","string").field("index","not_analyzed").endObject()
								.startObject("recordState").field("type","long").endObject()
								.startObject("isBlack").field("type","long").endObject()
								.startObject("isAlive").field("type","long").endObject()
								.startObject("joinCount").field("type","long").endObject()
								.startObject("registrarName").field("type","string").field("index","not_analyzed").endObject()
								.startObject("cnDomainName").field("type","string").field("index","not_analyzed").endObject()
								.startObject("joinUnitIds").field("type","string").field("index","not_analyzed").endObject()
								.startObject("industryType").field("type","string").field("index","not_analyzed").endObject()
								.startObject("industryTypeName").field("type","string").field("index","not_analyzed").endObject()
								.startObject("qzzxSpCjlx").field("type","string").field("index","not_analyzed").endObject()
								.startObject("qzzxSpCjlxName").field("type","string").field("index","not_analyzed").endObject()
								.startObject("findTime").field("type","date").field("format","yyyy-MM-dd HH:mm:ss").endObject()
								.startObject("detectionTime").field("type","date").field("format","yyyy-MM-dd HH:mm:ss").endObject()
								.startObject("sfCdn").field("type","long").field("index","not_analyzed").endObject()
								.startObject("ips").field("type","string").field("index","not_analyzed").endObject()
								.startObject("jrsIds").field("type","long").endObject()
								.startObject("jrsMcs").field("type","string").field("index","no").endObject()
								.startObject("idcIspIds").field("type","string").field("index","not_analyzed").endObject()
								.startObject("houseCodes").field("type","string").field("index","not_analyzed").endObject()
								.startObject("shengIds").field("type","long").field("index","no").endObject()
								.startObject("shiIds").field("type","long").field("index","no").endObject()
								.startObject("xianIds").field("type","long").field("index","no").endObject()
					.endObject()
				.endObject();
		return mapping;
	}

	@Override
	public XContentBuilder buildEntity(TopDomainIndex entity) throws IOException {
		return null;
	}

	@Override
	public TopDomainIndex recoveEntity(Map<String, Object> propertiesMap) {
		return null;
	}

	@Override
	public XContentBuilder buildUpdateEntity(TopDomainIndex entity) throws IOException {
		return null;
	}

	@Override
	public TopDomainIndex recoveEntityAndIndex(Map<String, Object> propertiesMap,SearchHit arrHits) {
		return null;
	}
}
